<admintpl file="header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a>逾期列表</a></li>
			<li><a href="{:U('Examine/loan_overdue_buyer')}">我的客户</a></li>
		</ul>
		<form class="well form-search" method="post" action="{:U('Examine/loan_overdue')}" style="line-height: 46px;">
			手机号码： 
			<input type="text" name="mobile" style="width: 200px;" value="{:I('request.mobile')}" placeholder="请输入手机号码">
			姓名： 
			<input type="text" name="name" style="width: 200px;" value="{:I('request.name')}" placeholder="姓名">
			逾期时间：<input class="js-date" type="text" name="starts" style="width: 200px;" value="{:I('request.starts')}" placeholder="起始时间">
			<input class="js-date" type="text" name="ends" style="width: 200px;" value="{:I('request.ends')}" placeholder="结束时间">
			<br />
			认领状态：<select name="byusers">
				<php>$tpl_selected=I('request.byusers')=='3'?"selected":"";</php>
				<php>$tpl_selected=(I('request.byusers')=='' && get_current_admin_id()==1)?"selected":$tpl_selected;</php>
				<option {$tpl_selected} value="3">全部</option>
				<php>$tpl_selected=I('request.byusers')=='1'?"selected":"";</php>
				<option {$tpl_selected} value="1">未认领</option>
				<php>$tpl_selected=I('request.byusers')=='2'?"selected":"";</php>
				<!--<php>$tpl_selected=(I('request.byusers')=='' && get_current_admin_id()!=1)?"selected":$tpl_selected;</php>-->
				<option {$tpl_selected} value="2">我的客户</option>
			</select>
			风控专员： 
			<input type="text" name="fengkong" style="width: 200px;" value="{:I('request.fengkong')}" placeholder="风控专员">
			财务专员： 
			<input type="text" name="caiwu" style="width: 200px;" value="{:I('request.caiwu')}" placeholder="财务专员">
			贷后专员(保留)：
			<input type="text" name="daihou" style="width: 200px;" value="{:I('request.daihou')}" placeholder="贷后专员" />
			<br/>
			M1专员：
			<input type="text" name="mone" style="width: 200px;" value="{:I('request.mone')}" placeholder="M1专员" />
			M2专员：
			<input type="text" name="mtwo" style="width: 200px;" value="{:I('request.mtwo')}" placeholder="M2专员" />
			逾期状态：
			<php>$overdue_status_arr = [['key'=>'1','name'=>'M1'],['key'=>'2','name'=>'M2']];</php>
			<select name="overdue_m_status">
				<option value="-1">全部</option>
				<foreach name="overdue_status_arr" item="os">
					<php>$tpl_selected=I('request.overdue_m_status')==$os['key']?"selected":"1";</php>
					<option {$tpl_selected} value="{$os['key']}">{$os['name']}</option>
				</foreach>
			</select>
			客户类型：
			<select name="is_adult">
				<option value="-1">全部</option>
				<php>$tpl_selected=I('request.is_adult')=='0'?"selected":"";</php>
				<option {$tpl_selected} value="0">未知</option>
				<php>$tpl_selected=I('request.is_adult')=='1'?"selected":"";</php>
				<option {$tpl_selected} value="1">成人</option>
				<php>$tpl_selected=I('request.is_adult')=='2'?"selected":"";</php>
				<option {$tpl_selected} value="2">学生</option>
			</select>
			<br/>
			渠道来源：<input type="text" name="qudao" style="width: 150px;" value="{:I('request.qudao')}" placeholder="渠道来源">
			逾期类型：
			<select name="collection_type">
				<option value="0">全部</option>
				<foreach name="collection_type" item="os" key='k'>
					<php>$tpl_selected=I('request.collection_type')==$k?"selected":'';</php>
					<option {$tpl_selected} value="{$k}">{$os}</option>
				</foreach>
			</select>
			<input type="submit" class="btn btn-primary" value="搜索" />
			<a class="btn btn-danger" href="">清空</a>
			 <button class="btn btn-primary js-ajax-submit" type="button" id='add_bate' data-action="{:U('Examine/bate_add',array('display'=>1))}" onclick='check(1)' >贷后批量认领</button>
			<php>$group=get_groups_admin_user();</php>
			<if condition="($group eq 1 || $group eq 8 || $group eq 10 || $group eq 7)">
				<button class="btn btn-primary js-ajax-trf" type="button" id='trf_bate' data-action="{:U('Examine/transferDaihou')}" onclick='trf()' >转让</button>
			</if>
		</form>
		<form method="post" class="js-ajax-form">
			<table class="table table-hover table-bordered">
				<thead>
					<tr>
						<th align="center">选择</th>
						<th>{:L('MOBILE')}</th>
						<th>{:L('USERS_NAME')}</th>
						<th>身份证号码</th>
						<th>{:L('AMOUNT')}</th>
						<th>{:L('EXAM_WEEK')}</th>
						<th>还款时间</th>
						<th>{:L('USER_TYPE')}</th>
						<th>{:L('EXAM_TYPE')}</th>
						<th>风控专员</th>
						<th>贷后专员</th>
						<th>M1专员</th>
						<th>M2专员</th>
						<th>财务专员</th>
						<th>客户类型</th>
						<th>渠道来源</th>
						<th>逾期类型</th>
						<th align="center">{:L('ACTIONS')}</th>
					</tr>
				</thead>
				<tbody>
					<foreach name="list" item="vo">
					<tr>
						<td><input type='checkbox' name='id[]' value='{$vo.user_id}'/></td>
						<td>{$vo.mobile}</td>
						<td><a href="{:U('Examine/overdue_info',array('id'=>$vo['id']))}" >{$vo.name}</a></td>
						<td>{$vo.identity}</td>
						<td>{$vo.amount}</td>
						<td>{$vo.loan_day}天</td>
						<td>{$vo.sub_endtime}</td>
						<php>$ds=array('0'=>'<span style="color:red">未认证</span>','1'=>'<span style="color:green">已认证</span>','2'=>'<span style="color:red">认证未通过</span>','3'=>'<span style="color:red">暂时不需要</span>')</php>
						<td>{$ds[$vo['account_status']]}</td>
						<td><if condition="($vo.status eq 0)">待审核
							<elseif condition="$vo.status eq 1"/>借款中
							<elseif condition="$vo.status eq 2"/>已还款
							<elseif condition="$vo.status eq 3"/>逾期<br/>阶段:M{$vo['overdue_m_status']}
							<elseif condition="$vo.status eq 4"/>已到期
							<elseif condition="$vo.status eq 5"/>审核中
							<elseif condition="$vo.status eq 6"/>审核不通过
							<elseif condition="$vo.status eq 7"/>驳回
							<elseif condition="$vo.status eq 8"/>放款成功
							<elseif condition="$vo.status eq 9"/>放款不成功
							<elseif condition="$vo.status eq 10"/>待放款
							</if></td>
						<td>{$users[$vo['byusers']]}</td>
						<td>{$users[$vo['byusers_loan']]}</td>
						<td>{$users[$vo['byusers_loan_m1']]}</td>
						<td>{$users[$vo['byusers_loan_m2']]}</td>
						<td>{$vo.loan_user}</td>
						<td>
							<if condition="$vo['is_adult'] eq 0">未知
								<elseif condition="$vo['is_adult'] eq 1"/>成人
								<elseif condition="$vo['is_adult'] eq 2"/>学生
							</if>
						</td>
						<td>{$codes[$vo['code']]}</td>
						<td>
						<php>$coll_type=explode(',',$vo['collection_type'])</php>
						<foreach name="coll_type" item="vos">
							{$collection_type[$vos]}<br/>
						</foreach>
						</td>
						<td align="center">
							<a href="{:U('Examine/fuwujkxy',array('id'=>$vo['id']))}" >借款协议</a>
							<br/>|<a href="{:U('Examine/after_collection',array('id'=>$vo['id']))}">催收后记</a>
							<br/>|<a href="{:U('Examine/overdue_exam',array('id'=>$vo['id']))}" >逾期还款审核</a>
							<br/>|<a href="{:U('Examine/overdue_renwal',array('id'=>$vo['id']))}">逾期续期审核</a>
							<if condition="($group neq 9)">
								<if condition="($group neq 5)">
								<br/>|<a href="{:U('Examine/overdue_exam',array('id'=>$vo['id']))}" >逾期还款审核</a>
								<br/>|<a href="{:U('Examine/ban',array('id'=>$vo['id']))}" class="js-ajax-dialog-btn" data-msg="{$vo.name} 的借款是否确认添加到不催缴">添加到不催缴</a>
								<br/>|<a href="{:U('Examine/ban',array('id'=>$vo['id'],'third'=>1))}" class="js-ajax-dialog-btn" data-msg="{$vo.name} 的借款是否确认添加到第三方催缴?加入就不能变更">加入第三方催缴</a>
									<if condition="isset($rids) && !empty($rids)">
										<if condition="!in_array($vo['id'],$rids)">
											<br/>|<a href="{:U('Examine/overdue_renwal',array('id'=>$vo['id']))}">逾期续期审核</a>
										</if>
										<else />
										<br/>|<a href="{:U('Examine/overdue_renwal',array('id'=>$vo['id']))}">逾期续期审核</a>
									</if>
								<br/>|
									<?php $flag = in_array($vo['user_id'],$b_id_list);?>
									<if condition="$flag">
										<span style="color: red;">已在黑名单中</span>
										<else/>
										<a href="{:U('Indexadmin/yqAddBlack',array('id'=>$vo['id']))}">添加黑名单</a>
									</if>
								</if>
							</if>
						</td>
					</tr>
					</foreach>
				</tbody>
				<tfoot>
				<tr>
					<td>当页合计：</td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
				</tr>
				<tr>
					<td>总合计：</td>
					<td></td>
					<td></td>
					<td></td>
					<td>{$total_amount}</td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
				</tr>
				</tfoot>
			</table>
			<div class="pagination">{$page}</div>
		</form>
	</div>
	<div id="dialog" style='display:none' >
		<p>请选择转让的审核专员</p>
		<ul style='width: 500px;list-style-type:none;'>
			<php>$i=0;</php>
			<foreach name="shen_user" item="vo">
				<li style='width: 110px;float: left;'><input type="radio" name='us_id' value='{$vo.id}' style='margin: 0 0 0 10px;'/>{$vo.user_login}</li>
				<php>$i++;</php>
				<if condition="($i eq 4)"><br/>
					<php>$i=0;</php>
				</if>
			</foreach>
		</ul>
	</div>
	<script src="__PUBLIC__/js/common.js"></script>
	<script>
	function check(type){
			var btn = $('button.js-ajax-submit');
			form = $('form.js-ajax-form');
			var obj=document.getElementsByName('id[]'); 
			var s=0; 
			for(var i=0; i<obj.length; i++){ 
				if(obj[i].checked) s+=1; 
			}
			if(s==0){
				alert('请选择借款');
				return ;
			}
			form.ajaxSubmit({
	                url: type ? btn.data('action') : form.attr('action'),
	                //按钮上是否自定义提交地址(多按钮情况)
	                dataType: 'json',
	                beforeSubmit: function (arr, $form, options) {
						var tx='批量添加';
	                    //按钮文案、状态修改
	                    btn.text(tx + '中...').attr('disabled', true).addClass('disabled');
	                },
	                success: function (data, statusText, xhr, $form) {
	                    //按钮文案、状态修改
	                    btn.removeClass('disabled').parent().find('span').remove();
	
	                    if (data.state === 'success') {
	                        $('<span class="tips_success">' + data.info + '</span>').appendTo(btn.parent()).fadeIn('slow').delay(1000).fadeOut(function () {
	                            if (data.referer) {
	                                //返回带跳转地址
	                                if (window.parent.art) {
	                                    //iframe弹出页
	                                    window.parent.location.href = data.referer;
	                                } else {
	                                    window.location.href = data.referer;
	                                }
	                            } else {
	                                if (window.parent.art) {
	                                    reloadPage(window.parent);
	                                } else {
	                                    //刷新当前页
	                                    reloadPage(window);
	                                }
	                            }
	                        });
	                    } else if (data.state === 'fail') {
	                        $('<span class="tips_error">' + data.info + '</span>').appendTo(btn.parent()).fadeIn('fast');
	                        btn.removeProp('disabled').removeClass('disabled');
	                    }
	                }
	            });
	}

    function trf(){
        var btn = $('#trf_bate');
        form = $('form.js-ajax-form');
        var obj=document.getElementsByName('id[]');
        var s='';
        for(var i=0; i<obj.length; i++){
            if(obj[i].checked){
                if(s==''){
                    s=obj[i].value;
                }else{
                    s+=','+obj[i].value;
                }

            }
        }
        if(s==''){
            alert('请选择客户');
            return ;
        }
        href = btn.data('action'),
            href = href ? href : $this.attr('href');
        Wind.use('artDialog', function () {
            //document.getElementById("dialog").style.display='block';
            art.dialog({
                title: false,
                //icon: 'question',
                content: $("#dialog").html(),
                //content: '1111',
                follow: document.getElementById('trf_bate'),
                close: function () {
                    return true;
                },
                ok: function () {
                    var radio = document.getElementsByName("us_id");
                    var us_id=0;
                    for (i=0; i<radio.length; i++) {
                        if (radio[i].checked) {
                            us_id=radio[i].value;
                        }
                    }
                    if(us_id==0){
                        alert('请选择审核专员');
                        return false;
                    }
                    $.ajax({
                        url:href,
                        type:'post',
                        dataType:'json',
                        data:'users='+s+'&us_id='+us_id,
                        success:function(map){
                            if (map.state == 'success') {
                                art.dialog({
                                    content: map.info,
                                    icon: 'success',
                                    ok: function () {
                                        this.title(map.info);
                                        window.location.reload();
                                        return true;
                                    }
                                });
                            } else if (map.state == 'fail') {
                                //art.dialog.alert(data.info);
                                //alert(data.info);//暂时处理方案
                                art.dialog({
                                    content: map.info,
                                    icon: 'warning',
                                    ok: function () {
                                        this.title(map.info);
                                        return true;
                                    }
                                });
                            }
                        }

                    });
                },
                cancelVal: '关闭',
                cancel: true
            });
        });

    }
	</script>
	<script>
        $(function () {
            var arr = [4];//要取哪几列的合计
            var def = 'var ';
            for(var a in arr){
                def += ('total'+arr[a]+'=0,');
            }
            def=def.substring(0,def.length-1)+';';
            eval(def);//执行定义
            $('tbody tr').each(function() {
                for(var i in arr){
                    $(this).find('td:eq('+arr[i]+')').each(function(){
                        var tmp = $(this).text();
                        if(tmp === ''){
                            tmp = 0;
                        }
                        eval('total'+arr[i]+'+=parseFloat(tmp);');
                    });
                }
            });
            for(var x in arr){
                $('tfoot tr:eq(0)').find('td:eq('+arr[x]+')').text(eval('total'+arr[x]));
            }
        });
	</script>
</body>
</html>